import 'package:get/get.dart';

import 'country_model.dart';

class AreaCodeState {
  // 所有国家列表
  final RxList<AreaCodeModel> allCountries = <AreaCodeModel>[].obs;

  // 过滤后的国家列表
  final RxList<AreaCodeModel> filteredCountries = <AreaCodeModel>[].obs;

  // 选中的国家
  final Rx<AreaCodeModel?> selectedCountry = Rx<AreaCodeModel?>(null);

  // 过滤选项
  final Rx<CountryFilterOptions> filterOptions = CountryFilterOptions().obs;

  // 加载状态
  final RxBool isLoading = false.obs;

  // 错误信息
  final RxString errorMessage = ''.obs;
}

// 过滤选项
class CountryFilterOptions {
  final String keyword;
  final String region;
  final String language;

  CountryFilterOptions({
    this.keyword = '',
    this.region = '',
    this.language = '',
  });

  CountryFilterOptions copyWith({
    String? keyword,
    String? region,
    String? language,
  }) {
    return CountryFilterOptions(
      keyword: keyword ?? this.keyword,
      region: region ?? this.region,
      language: language ?? this.language,
    );
  }
}
